package com.squirrel.michale;

/**
 * @author guanhao 观浩
 * @version 1.0.0.0
 * @createTime 2023/3/31 6:06 AM
 * @company Michale Squirrel
 * @link
 * @description
 */
public class LeetCode2419 {

    public int longestSubarray(int[] nums) {
        int length = nums.length;
        int max = -1;
        for (int i = 0; i < length; i ++) {
            max = Math.max(max, nums[i]);
        }
        int result = 0;
        int temp = 0;
        for (int i = 0; i < length; i ++) {
            if (nums[i] == max) {
                temp ++;
            } else {
                temp = 0;
            }
            result = Math.max(result, temp);
        }
        return result;
    }
}
